package com.zapi.lottery.controller;

import com.zapi.lottery.entity.LotterySetting;
import com.zapi.lottery.service.LotterySettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * LotterySetting 控制器
 * 提供奖项设置的增删改查接口
 * @author: zhonglz
 * @DATE: 2024-06-09
 */
@RestController
@RequestMapping("/lottery/setting")
public class LotterySettingController {
    @Autowired
    private LotterySettingService lotterySettingService;

    /**
     * 新增或更新奖项设置
     */
    @PostMapping
    public boolean save(@RequestBody LotterySetting lotterySetting) {
        return lotterySettingService.saveOrUpdate(lotterySetting);
    }

    /**
     * 删除奖项设置
     */
    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable Integer id) {
        return lotterySettingService.removeById(id);
    }

    /**
     * 根据ID获取奖项设置
     */
    @GetMapping("/{id}")
    public LotterySetting getById(@PathVariable Integer id) {
        return lotterySettingService.getById(id);
    }

    /**
     * 获取所有奖项设置列表
     */
    @GetMapping
    public List<LotterySetting> findAll() {
        return lotterySettingService.list();
    }
} 